<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin:0;
            padding:0;
        }
        #box{
            height:100px;
            width:100px;
            border:5px solid red;
            overflow: auto;
        }
    </style>
</head>
<body>
    <div id="box" style="background-color: pink;color:green;">
        111
    </div>
    <script src="utils.js"></script>
   <script>
      //获取样式
      //无兼容
    //    function getCss(ele,style){
    //       return window.getComputedStyle(ele)[style];
    //    }
    //    console.log(getCss(box,"color"));
    //    console.log(getCss(box,"width"));

    //   function getCss(ele,style){
    //     if("getComputedStyle" in window){//true false
    //         return window.getComputedStyle(ele)[style];
    //     }else{//IE6-8  currentStyle
    //         return ele.currentStyle[style];
    //     }  
    //    }
       console.log(utils.getCss(box,"color"));
       console.log(utils.getCss(box,"width"));
   </script>
</body>
</html>